/**
[
    ['戴尔', '苹果', '联想'],
    ['笔记本', '平板电脑', 'PC机', '上网本'],
    ['黑色', '白色', '红色'],
]
输出:
[
    '戴尔-笔记本-黑色',
    '戴尔-笔记本-白色',
    '戴尔-笔记本-红色',
    '戴尔-平板电脑-黑色',
    '戴尔-平板电脑-白色',
    '戴尔-平板电脑-红色',
    ......
]
 */


const arr = [
    ['戴尔', '苹果', '联想'],
    ['笔记本', '平板电脑', 'PC机', '上网本'],
    ['黑色', '白色', '红色']
]

// const fn = (list) => {
//     let result = [[]];

//     function _fn(preList, curRow) {
//         const dtoRes = [];
//         for (let i = 0; i < preList.length; i++) {
//             for(let j = 0; j < curRow.length; j++) {
//                 console.log(preList[i], curRow[j])
//                 dtoRes.push([].concat(preList[i]).concat(curRow[j]));
//             }
//         }
//         result = dtoRes;
//     }

//     for (let i = 0; i < list.length; i++) {
//         _fn(result, list[i]);
//     }

//     return result.map(item => item.join('-'));
// }




const fn =  (list) => {
    let result = [[]]

    function _fn(preList, curRow) {
        const dtoRes = [];
        for(let i = 0 ; i < preList.length; i++) {
            for(let j = 0; j < curRow.length; j++) {
                dtoRes.push([].concat(preList[i]).concat(curRow[j]));
            }
        }
        result = dtoRes;

 
    }

    for (let i = 0; i < list.length; i++) {
        _fn(result, list[i]);
    }

    return result.map(item => {
        console.log(item)
        return item.join('-');
    });
}

console.log(fn(arr));